import 'package:get/get.dart';
import 'package:ljy_flutter/get/mvcdemo/getx_api_service.dart';
import 'package:ljy_flutter/get/mvcdemo/getx_movie_model.dart';

class GetxMovieController extends GetxController {
  var isloading = true.obs;
  var movies = <GetxMovieModel>[].obs;

  @override
  void onInit() {
    fetchMovie();
    super.onInit();
  }

  void fetchMovie() async {
    try {
      isloading.value = true;

      var movie = await GetxApiService.fetchMovieModels();

      if (movie != null) {
        movies.assignAll(movie);
      }
    } finally {
      isloading.value = false;
    }
  }
}
